package com.woniuxy.caradmin.controller;


import com.woniuxy.caradmin.entity.pojo.Repairshop;
import com.woniuxy.caradmin.exception.CarException;
import com.woniuxy.caradmin.service.RepairshopService;
import com.woniuxy.caradmin.util.Constaint;
import com.woniuxy.caradmin.util.R;
import com.woniuxy.caradmin.util.ResultCode;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author womenzu
 * @since 2020-12-07
 */
@RestController
@RequestMapping("/repairshop")
public class RepairshopController {
    @Autowired
    private RepairshopService repairshopService;
    @ApiOperation("查询所有的修理厂")
    @GetMapping("/selectAllRepairshop")
    public R selectAllRepairshop(){
        List<Repairshop> repairshops = repairshopService.selectAllRepairshop();
        if(repairshops!=null && repairshops.size()>0){
            return R.ok().code(ResultCode.DRIVERISNOTNULL).message(Constaint.DRIVERISNOTNULL)
                    .data("repairshops",repairshops);
        }else{
            throw new CarException(ResultCode.DRIVERISNULL,Constaint.DRIVERISNULL);
        }
    }

}

